
/* -----------------------------------------------------------------------
 * Chris Lewis
 * CS 362
 * Assignment 3: unittest3.c test of function discardCard() in dominion.c
 *
 * unittest3: unittest3.c dominion.o rngs.o
 *      gcc -o unittest3 -g  unittest3.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

//If NOISY is set to 0, then only an overall pass/fail will display.
//If NOISY is set to 1, then test information will be displayed as executed.
#define NOISY 1

int main() {
    int seed = 1000;                                                                                
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int crash;
    int startingHandCount;
    int startingCardCount;

    initializeGame(numPlayer, k, seed, &G);

    printf ("\n\n********* UNIT TEST 3 - discardCard() ************\n");

        startingHandCount = G.handCount[0];     
        startingCardCount = G.playedCardCount;
#if (NOISY == 1)
        printf("Beginning # of cards in hand: %d, discard pile count: %d\n", startingHandCount, startingCardCount);
#endif
        crash = discardCard(0, 0, &G, 0);                                               //trash flag off
        assert(crash == 0);                                                     
        assert(G.handCount[0] == startingHandCount - 1);                //-1 card in hand
        assert(G.playedCardCount == startingCardCount + 1);             //+1 card played
#if (NOISY == 1)
        printf("Ending # of cards in hand: %d, discard pile count: %d\n", G.handCount[0], G.playedCardCount);
#endif

        startingHandCount = G.handCount[0];     
        startingCardCount = G.playedCardCount;
#if (NOISY == 1)
        printf("Beginning # of cards in hand: %d, discard pile count: %d\n", startingHandCount, startingCardCount);
#endif
        crash= discardCard(1, 0, &G, 1);                                               //trash flag on
        assert(crash == 0);                                                     
        assert(G.handCount[0] == startingHandCount - 1);                //-1 card in hand
        assert(G.playedCardCount == startingCardCount);                 //no change in card played amount
#if (NOISY == 1)
        printf("Ending # of cards in hand: %d, discard pile count: %d\n", G.handCount[0], G.playedCardCount);
#endif

    printf("discardCard(): PASS\n");

    return 0;
}